<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="README" />
	<meta name="description" content="README" />
	<!-- 网页标签标题 -->
	<title>README</title>
	<link rel="shortcut icon" href="/img/docsite.ico"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/zh-cn/index.html"><img class="logo" src="/pic/icon_name_black.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">En</span><div class="header-menu"><img class="header-menu-toggle" src="/img/system/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/zh-cn/index.html" target="_self">首页</a></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="/zh-cn/docs/README.html" target="_self">文档</a></li></ul></div></div></header><div class="bar"><div class="bar-body"><img src="/img/system/docs.png" class="front-img"/><span>文档</span><img src="/img/system/docs.png" class="back-img"/></div></div><section class="content-section"><div class="sidemenu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>使用文档</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/README.html" target="_self">介绍</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/FASTSTART.html" target="_self">快速开始</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/update.html" target="_self">版本升级</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/zh-cn/docs/HELP.html" target="_self">后台使用指南</a></li></ul></li></ul></div><div class="doc-content markdown-body"><h2 id="plumelog-lite">plumelog-lite <a class="header-anchor" href="#plumelog-lite">#</a></h2>
<h4 id="plumelog-lite%E7%89%88%E6%9C%AC%EF%BC%8C%E4%B8%8D%E7%94%A8%E9%83%A8%E7%BD%B2%E7%9B%B4%E6%8E%A5%E5%BC%95%E7%94%A8%E5%88%B0%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8">plumelog-lite版本，不用部署直接引用到项目中直接使用 <a class="header-anchor" href="#plumelog-lite%E7%89%88%E6%9C%AC%EF%BC%8C%E4%B8%8D%E7%94%A8%E9%83%A8%E7%BD%B2%E7%9B%B4%E6%8E%A5%E5%BC%95%E7%94%A8%E5%88%B0%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8">#</a></h4>
<h4 id="%E5%8A%9F%E8%83%BD%E5%8C%85%E5%90%AB%EF%BC%8C%E6%97%A5%E5%BF%97%E6%9F%A5%E8%AF%A2%EF%BC%8C%E9%93%BE%E8%B7%AF%E8%BF%BD%E8%B8%AA%EF%BC%8C%E6%97%A5%E5%BF%97%E7%AE%A1%E7%90%86%EF%BC%8C%E9%80%82%E5%90%88%E5%8D%95%E6%9C%BA%E5%B0%8F%E8%A7%84%E6%A8%A1%E9%A1%B9%E7%9B%AE%E4%BD%BF%E7%94%A8%2C%E7%9B%AE%E5%89%8D%E5%8F%AA%E6%94%AF%E6%8C%81springboot%2Blogback%EF%BC%8Clog4j2%E7%BB%84%E5%90%88">功能包含，日志查询，链路追踪，日志管理，适合单机小规模项目使用,目前只支持springboot+logback，log4j2组合 <a class="header-anchor" href="#%E5%8A%9F%E8%83%BD%E5%8C%85%E5%90%AB%EF%BC%8C%E6%97%A5%E5%BF%97%E6%9F%A5%E8%AF%A2%EF%BC%8C%E9%93%BE%E8%B7%AF%E8%BF%BD%E8%B8%AA%EF%BC%8C%E6%97%A5%E5%BF%97%E7%AE%A1%E7%90%86%EF%BC%8C%E9%80%82%E5%90%88%E5%8D%95%E6%9C%BA%E5%B0%8F%E8%A7%84%E6%A8%A1%E9%A1%B9%E7%9B%AE%E4%BD%BF%E7%94%A8%2C%E7%9B%AE%E5%89%8D%E5%8F%AA%E6%94%AF%E6%8C%81springboot%2Blogback%EF%BC%8Clog4j2%E7%BB%84%E5%90%88">#</a></h4>
<p>示例中plumelog相关版本号为示例，实际使用建议取最新的版本，最新的版如下</p>
<p><a href="https://maven-badges.herokuapp.com/maven-central/com.plumelog/plumelog">最新的版本号：<img src="https://maven-badges.herokuapp.com/maven-central/com.plumelog/plumelog-lite/badge.svg" alt="Maven Status"></a></p>
<ol>
<li>引入</li>
</ol>
<pre><code class="language-xml">
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.plumelog<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>plumelog-lite<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.5.2<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>

</code></pre>
<ul>
<li>或者引用plumelog-lite-spring-boot-starter，则不需要配置扫描路径和静态文件路径</li>
</ul>
<pre><code class="language-xml">
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.plumelog<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>plumelog-lite-spring-boot-starter<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.5.2<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>

</code></pre>
<ol start="2">
<li>配置logback.xml</li>
</ol>
<pre><code class="language-xml">
<span class="hljs-tag">&lt;<span class="hljs-name">appender</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"plumelog"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"com.plumelog.lite.logback.appender.LiteAppender"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">appName</span>&gt;</span>plumelog<span class="hljs-tag">&lt;/<span class="hljs-name">appName</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- 日志存储位置 --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">logPath</span>&gt;</span>/plumelog/lite<span class="hljs-tag">&lt;/<span class="hljs-name">logPath</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- 日志保留天数 --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">keepDay</span>&gt;</span>30<span class="hljs-tag">&lt;/<span class="hljs-name">keepDay</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">appender</span>&gt;</span>
        
        <span class="hljs-comment">&lt;!-- 添加 ref--&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">root</span> <span class="hljs-attr">level</span>=<span class="hljs-string">"INFO"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">appender-ref</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"plumelog"</span>/&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">root</span>&gt;</span>

</code></pre>
<ol start="3">
<li>在springboot启动类里添加扫描路径，注意：如果原来你的项目没有扫描路径，不要只加这个，也要把你自己的项目的加了，不然只扫描plumelog的路径了</li>
</ol>
<pre><code class="language-java"><span class="hljs-meta">@ComponentScan</span>(<span class="hljs-string">"com.plumelog"</span>)
</code></pre>
<p>情况一：如果你的项目访问plumelog页面空白，说明没有配置可以访问静态文件请做如下配置 在application.properties配置：</p>
<pre><code class="language-properties"><span class="hljs-meta">spring.mvc.static-path-pattern</span>=<span class="hljs-string">/**</span>
<span class="hljs-meta">spring.resources.static-locations</span>=<span class="hljs-string">classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/</span>
</code></pre>
<p>情况二：拦截器会覆盖spring.resources.static-locations，如果项目中有拦截器，需要在拦截器里配置静态文件访问</p>
<p>示例：</p>
<pre><code class="language-java"><span class="hljs-keyword">import</span> com.plumelog.core.PlumeLogTraceIdInterceptor;
<span class="hljs-keyword">import</span> org.springframework.context.annotation.Configuration;
<span class="hljs-keyword">import</span> org.springframework.web.servlet.config.annotation.InterceptorRegistry;
<span class="hljs-keyword">import</span> org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
<span class="hljs-keyword">import</span> org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

<span class="hljs-meta">@Configuration</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TraceIdInterceptorsConfig</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">WebMvcConfigurerAdapter</span></span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> String[] CLASSPATH_RESOURCE_LOCATIONS = {<span class="hljs-string">"classpath:/META-INF/resources/"</span>, <span class="hljs-string">"classpath:/resources/"</span>, <span class="hljs-string">"classpath:/static/"</span>, <span class="hljs-string">"classpath:/public/"</span>};
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">addResourceHandlers</span><span class="hljs-params">(ResourceHandlerRegistry registry)</span> </span>{
        <span class="hljs-comment">//就是这句addResourceLocations，加上静态文件访问路径</span>
        registry.addResourceHandler(<span class="hljs-string">"/**"</span>).addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
    }
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">addInterceptors</span><span class="hljs-params">(InterceptorRegistry registry)</span> </span>{
        registry.addInterceptor(<span class="hljs-keyword">new</span> PlumeLogTraceIdInterceptor());
        <span class="hljs-keyword">super</span>.addInterceptors(registry);
    }

}



</code></pre>
<ol start="4">
<li>访问</li>
</ol>
<p>启动你的项目：输入你的项目地址+plumelog/#/访问，例如：<a href="http://localhost:8083/plumelog/#/">http://localhost:8083/plumelog/#/</a> 一定要加这个/#/后缀</p>
<ol start="5">
<li>异常处理</li>
</ol>
<ul>
<li>Lock held by this virtual machine 处理</li>
</ul>
<p>有些用3.5版本会报错：org.apache.lucene.store.LockObtainFailedException: Lock held by this virtual machine</p>
<p>情况一：springcloud-alibaba需要在你的启动类里面加：System.setProperty(&quot;spring.cloud.bootstrap.enabled&quot;, &quot;false&quot;);</p>
<p>示例：</p>
<pre><code class="language-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        System.setProperty(<span class="hljs-string">"spring.cloud.bootstrap.enabled"</span>, <span class="hljs-string">"false"</span>);
        SpringApplication.run(LogServerStart<span class="hljs-class">.<span class="hljs-keyword">class</span>, <span class="hljs-title">args</span>)</span>;
        }

</code></pre>
<p>情况二：如果用的logback.xml 改成logback-spring.xml;</p>
<p>情况三：用3.5.1以后版本</p>
<ul>
<li>项目不是根目录导致，滚动日志无法连接</li>
</ul>
<p>用3.5.2版本</p>
</div></section><footer class="footer-container"><div class="footer-body"><img src="/pic/icon_name_black.png"/><div class="cols-container"><div class="col col-12"><h3>免责声明</h3><p>本软件为免费软件并开放源码，用于交流学习，使用中遇到任何问题和纠纷本社区概不负责</p></div><div class="col col-6"><dl><dt>文档</dt><dd><a href="/zh-cn/docs/FASTSTART.html" target="_self">概览</a></dd><dd><a href="/zh-cn/docs/FASTSTART.html" target="_self">快速开始</a></dd><dd><a href="/zh-cn/docs/FASTSTARThtml" target="_self">开发者指南</a></dd></dl></div><div class="col col-6"><dl><dt>资源</dt><dd><a href="http://demo.plumelog.com" target="_self">演示地址</a></dd><dd><a href="https://gitee.com/plumeorg" target="_self">社区</a></dd></dl></div></div><div class="copyright"><span>Copyright © 2018 版权所有 plume开源社区</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
</body>
</html>